<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;

/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
    * @var yiike\order\model\OrderStoreSearch $searchModel
*/

$this->title = Yii::t('models', '订单');
$this->params['breadcrumbs'][] = $this->title;

if (isset($actionColumnTemplates)) {
$actionColumnTemplate = implode(' ', $actionColumnTemplates);
    $actionColumnTemplateString = $actionColumnTemplate;
} else {
Yii::$app->view->params['pageButtons'] = Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']);
    $actionColumnTemplateString = "{view} ";
}
$actionColumnTemplateString = '<div class="action-buttons">'.$actionColumnTemplateString.'</div>';
?>
<div class="box box-info giiant-crud order-store-index">
    <div class="box-header with-border">
        <div class="box-title">
            <?= Yii::t('models', '订单列表') ?>
        </div>
    </div>
    <div class="box-body">
    <?php
//             echo $this->render('_search', ['model' =>$searchModel]);
        ?>

    
    <?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>


    <div class="clearfix crud-navigation">
        <div class="pull-left">
          <!--  <?= Html::a('<span class="glyphicon glyphicon-plus"></span> ' . '新增', ['create'], ['class' => 'btn btn-success']) ?>-->
        </div>

        <div class="pull-right">

                                                    
          <!--  <?=
            \yii\bootstrap\ButtonDropdown::widget(
            [
            'id' => 'giiant-relations',
            'encodeLabel' => false,
            'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . '关联',
            'dropdown' => [
            'options' => [
            'class' => 'dropdown-menu-right'
            ],
            'encodeLabels' => false,
            'items' => [
            [
                'url' => ['order/index'],
                'label' => '<i class="glyphicon glyphicon-arrow-left"></i> ' . Yii::t('models', 'Order'),
            ],
                    
]
            ],
            'options' => [
            'class' => 'btn-default'
            ]
            ]
            );
            ?>-->
        </div>
    </div>

    <hr />


    <div class="table-responsive">
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'pager' => [
        'class' => yii\widgets\LinkPager::className(),
        'firstPageLabel' => '首页',
        'lastPageLabel' => '末页',
        ],
                    'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
        'headerRowOptions' => ['class'=>'x'],
        'columns' => [

                [
            'class' => 'yii\grid\ActionColumn',

            'template' => $actionColumnTemplateString,
            'buttons' => [
                'view' => function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', '详情'),
                        'aria-label' => Yii::t('cruds', '查看'),
                        'data-pjax' => '0',
                        'class' => 'btn btn-default btn-xs',
                    ];
                    return Html::a('<span class="fa fa-file-o"></span>', $url, $options);
                },
                'update' => function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', 'View'),
                        'aria-label' => Yii::t('cruds', 'View'),
                        'data-pjax' => '0',
                        'class' => 'btn btn-default btn-xs',
                    ];
                    return Html::a('<span class="fa fa-pencil-square-o"></span>', $url, $options);
                },
                'delete' => function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', 'View'),
                        'aria-label' => Yii::t('cruds', 'View'),
                        'data-pjax' => '0',
                        'class' => 'btn btn-default btn-xs',
                        'data-confirm' => '' . '确认删除?' . '',
                        'data-method' => 'post',
                    ];
                    return Html::a('<span class="fa fa-trash-o"></span>', $url, $options);
                },
            ],
            'urlCreator' => function($action, $model, $key, $index) {
                // using the column name as key, not mapping to 'id' like the standard generator
                $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
                $params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
                return Url::toRoute($params);
            },
            'contentOptions' => ['nowrap'=>'nowrap']
        ],
            [
                'label'=>'ID',
                'attribute'=>'id',

            ],
            'trade_id',
            [
                'label'=>'收货人',
                'attribute'=>'order.name',

            ],
            'order.mobile',
            [
                'label'=>'商家',
                'attribute'=>'store.title',

            ],
            'total',
            [
                'attribute' => '发货时间',
                'value' => function ($model) {
                    if($model->express_at!=0){
                        return  $model->express_at;
                    }else{
                        return '';
                    }

                },
            ],

            'express_name',
            'express_no',
            'order.trade_id',
            'order.memo',
            [
                'label'=>'状态',
                // 'format'=>'raw',
                'attribute'=>'status',
                'content'=>function($model){
                    if($model->status==0){
                        return Html::label('代付款','',['class'=>'label label-default']);
                    }else if($model->status==1){
                        return Html::label('已付款','',['class'=>'label label-info']);
                    }else if($model->status==2){
                        return Html::label('已发货','',['class'=>'label label-primary']);
                    }else if($model->status==3){
                        return Html::label('已完成','',['class'=>'label label-success']);
                    }else{
                        return Html::label('已取消','',['class'=>'label label-warning']);
                    }
                },
                'filter' => [0=>'代付款',1=>'已付款',2=>'已发货',3=>'已完成',4=>'已取消'],//重点在这里，传入一个数组，会下拉框显示
            ],
			/*'status',*/
			/*'is_refund',*/
			/*'finished_at',*/

			/*'quan',*/
			/*'commision',*/
			/*'settlement',*/
			/*'credit1',*/
			/*'credit2',*/
			/*'credit3',*/
			/*'credit4',*/
			/*'credit5',*/
			/*'credit3_pay',*/
			/*'real_pay',*/
			/*'refund_amount',*/
			/*'express_at',*/
			/*'uniontid',*/
			/*'express_name',*/
			/*'express_code',*/
			/*'express_no',*/
        ],
        ]); ?>
    </div>
        <?php \yii\widgets\Pjax::end() ?>
    </div>
</div>




